﻿using BusinessLogic;
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ACM
{
    public partial class ChangePassword : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            if (txtOldPassweord.Text != CurrentUser.user_password)
                lblWrongPassword.Visible = true;
            else
            {
                AddEditUserCommand cmd = new AddEditUserCommand(CurrentUser.id, txtNewPassweord.Text);
                cmd.Execute();
                if ((int)cmd.Result == 0)
                    Status.ShowError("เปลี่ยนรหัสผ่านไม่สำเร็จ");
                else
                {
                    CurrentUser.user_password = txtNewPassweord.Text;
                    Response.Redirect("SearchCarAdvance.aspx");
                }
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("SearchCarAdvance.aspx");
        }
    }
}